package com.pdd.mall.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pdd.mall.common.api.CommonResult;
import com.pdd.mall.entity.Review;
import com.pdd.mall.service.ReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 商品评价控制器
 */
@RestController
@RequestMapping("/products/{productId}/reviews")
public class ProductReviewController {

    @Autowired
    private ReviewService reviewService;
    
    /**
     * 获取商品评价列表
     */
    @GetMapping
    public CommonResult<Page<Review>> getProductReviews(
            @PathVariable Long productId,
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        Page<Review> reviewList = reviewService.getProductReviews(productId, pageNum, pageSize);
        return CommonResult.success(reviewList);
    }
}
